<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>LCV Framework: gpio-linux32.c Quellcode</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Erzeugt von Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Hauptseite</span></a></li>
    <li><a href="classes.html"><span>Datenstrukturen</span></a></li>
    <li class="current"><a href="files.html"><span>Dateien</span></a></li>
  </ul>
</div>
<h1>gpio-linux32.c</h1><a href="gpio-linux32_8c.html">gehe zur Dokumentation dieser Datei</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include "<a class="code" href="gpio_8h.html" title="Die Schnittstelle zu den GPIO Ports.">gpio.h</a>"</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include "<a class="code" href="gpio-port-config_8h.html" title="Enthält die Geräteadressen der GPIO Ports.">gpio-port-config.h</a>"</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include "<a class="code" href="log_8h.html" title="Ein Werkzeug zur Protokollierung.">log.h</a>"</span>
<a name="l00014"></a>00014 
<a name="l00018"></a>00018 <span class="keywordtype">void</span> <a class="code" href="gpio-linux32_8c.html#bc334897486c97709a88cb9e9c58e69e" title="Initialisiert das gpio_values[] Array.">lcv_gpio_init</a>();
<a name="l00019"></a>00019 
<a name="l00023"></a><a class="code" href="gpio-linux32_8c.html#e08fd5bb5dca37495060b34f5ac5cfd2">00023</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="gpio-linux32_8c.html#e08fd5bb5dca37495060b34f5ac5cfd2" title="Wurden die Ports bereits initialisiert.">gpio_initialised</a> = <a class="code" href="lcv-config_8h.html#a93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00024"></a>00024 
<a name="l00028"></a><a class="code" href="gpio-linux32_8c.html#a77a5b5803345c350546066730a87e22">00028</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="gpio-linux32_8c.html#a77a5b5803345c350546066730a87e22" title="Array zur Simulation der GPIO Ports.">gpio_values</a>[<span class="keyword">sizeof</span>(<a class="code" href="gpio-port-config_8h.html#6b55fc7a71bf7f25cda252b9a6756d28" title="Array mit Deviceadressen der In-Ports.">gpio_in</a>) / <span class="keyword">sizeof</span>(*<a class="code" href="gpio-port-config_8h.html#6b55fc7a71bf7f25cda252b9a6756d28" title="Array mit Deviceadressen der In-Ports.">gpio_in</a>)];
<a name="l00029"></a>00029 
<a name="l00033"></a><a class="code" href="gpio-linux32_8c.html#8e3ff06079c314fdf78536856b9e19da">00033</a> void (*<a class="code" href="gpio-linux32_8c.html#8e3ff06079c314fdf78536856b9e19da" title="Function-Pointer auf den GPIO-Output-Handler.">gpio_write_handler</a>)(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> port, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> value) = NULL;
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 
<a name="l00036"></a><a class="code" href="gpio_8h.html#c1091625d45beae7dbadf8b575f5a3b2">00036</a> <span class="keywordtype">char</span> <a class="code" href="gpio-linux32_8c.html#c1091625d45beae7dbadf8b575f5a3b2" title="Liest den Wert eines Eingabeports.">lcv_gpio_read</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> port)
<a name="l00037"></a>00037 {       
<a name="l00038"></a>00038         <a class="code" href="gpio-linux32_8c.html#bc334897486c97709a88cb9e9c58e69e" title="Initialisiert das gpio_values[] Array.">lcv_gpio_init</a>();
<a name="l00039"></a>00039         <span class="keywordflow">if</span> (port &lt; <a class="code" href="gpio-port-config_8h.html#87d7aa3bf12e9fe7185f732138ca1323" title="Anzahl In-Ports.">gpio_in_ports_cnt</a>) {
<a name="l00040"></a>00040                 <span class="keywordflow">return</span> <a class="code" href="gpio-linux32_8c.html#a77a5b5803345c350546066730a87e22" title="Array zur Simulation der GPIO Ports.">gpio_values</a>[port];
<a name="l00041"></a>00041         } <span class="keywordflow">else</span> {
<a name="l00042"></a>00042                 <span class="keywordflow">return</span> <a class="code" href="lcv-config_8h.html#db1d839e5201fcf44c454f8596cfd9af">ERROR_ILLEGAL_PORT</a>;
<a name="l00043"></a>00043         }
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="gpio_8h.html#b9f8e9e1180ce0f6c40fc07382807c07">00046</a> <span class="keywordtype">char</span> <a class="code" href="gpio-linux32_8c.html#b9f8e9e1180ce0f6c40fc07382807c07" title="Schreibt den Wert eines Ausgabeports.">lcv_gpio_write</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> port, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> value)
<a name="l00047"></a>00047 {       
<a name="l00048"></a>00048         <span class="keywordflow">if</span> (port &lt; <a class="code" href="gpio-port-config_8h.html#e62a1686c442c3939078c191a0db01c7" title="Anzahl Out-Ports.">gpio_out_ports_cnt</a>) {
<a name="l00049"></a>00049                 <span class="keywordflow">if</span> (<a class="code" href="gpio-linux32_8c.html#8e3ff06079c314fdf78536856b9e19da" title="Function-Pointer auf den GPIO-Output-Handler.">gpio_write_handler</a> != 0) { 
<a name="l00050"></a>00050                         (*gpio_write_handler) (port, value);
<a name="l00051"></a>00051                 }
<a name="l00052"></a>00052                 <span class="keywordtype">char</span> log_entry[256];
<a name="l00053"></a>00053                 sprintf (log_entry, <span class="stringliteral">"GPIO port Number %u was written to %u"</span>, port, value);                      
<a name="l00054"></a>00054                 <a class="code" href="log_8c.html#64e28a98e670fc7cd88d040fe59c2f5d" title="Schreibt einen Eintrag in die Protokolldatei.">lcv_log</a>(log_entry);
<a name="l00055"></a>00055                 
<a name="l00056"></a>00056                 
<a name="l00057"></a>00057                 <span class="keywordflow">return</span> <a class="code" href="lcv-config_8h.html#a8cecfc5c5c054d2875c03e77b7be15d" title="Booleans.">TRUE</a>;            
<a name="l00058"></a>00058         } <span class="keywordflow">else</span> {
<a name="l00059"></a>00059                 <span class="keywordflow">return</span> <a class="code" href="lcv-config_8h.html#db1d839e5201fcf44c454f8596cfd9af">ERROR_ILLEGAL_PORT</a>;
<a name="l00060"></a>00060         }
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 
<a name="l00063"></a><a class="code" href="gpio-linux32_8c.html#bc334897486c97709a88cb9e9c58e69e">00063</a> <span class="keywordtype">void</span> <a class="code" href="gpio-linux32_8c.html#bc334897486c97709a88cb9e9c58e69e" title="Initialisiert das gpio_values[] Array.">lcv_gpio_init</a>()
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065         <span class="keywordflow">if</span> (!<a class="code" href="gpio-linux32_8c.html#e08fd5bb5dca37495060b34f5ac5cfd2" title="Wurden die Ports bereits initialisiert.">gpio_initialised</a>) {
<a name="l00066"></a>00066                 <span class="keywordtype">int</span> i;
<a name="l00067"></a>00067                 
<a name="l00068"></a>00068                 <span class="keywordflow">for</span> (i=0; i&lt;<a class="code" href="gpio-port-config_8h.html#87d7aa3bf12e9fe7185f732138ca1323" title="Anzahl In-Ports.">gpio_in_ports_cnt</a>; i++) {
<a name="l00069"></a>00069                         <a class="code" href="gpio-linux32_8c.html#a77a5b5803345c350546066730a87e22" title="Array zur Simulation der GPIO Ports.">gpio_values</a>[i] = 1;
<a name="l00070"></a>00070                 }               
<a name="l00071"></a>00071                 <a class="code" href="gpio-linux32_8c.html#e08fd5bb5dca37495060b34f5ac5cfd2" title="Wurden die Ports bereits initialisiert.">gpio_initialised</a> = <a class="code" href="lcv-config_8h.html#a8cecfc5c5c054d2875c03e77b7be15d" title="Booleans.">TRUE</a>;
<a name="l00072"></a>00072         }
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 
<a name="l00076"></a><a class="code" href="gpio_8h.html#fe074e107ea0df9a1e7becc8cd65cc04">00076</a> <span class="keywordtype">void</span> <a class="code" href="gpio-linux32_8c.html#fe074e107ea0df9a1e7becc8cd65cc04" title="Simuliert einen Input an einem GPIO Port.">lcv_gpio_simulate_input</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> port, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> value)
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078         <span class="keywordflow">if</span> (port &lt; <a class="code" href="gpio-port-config_8h.html#e62a1686c442c3939078c191a0db01c7" title="Anzahl Out-Ports.">gpio_out_ports_cnt</a>) {
<a name="l00079"></a>00079                 <span class="keywordflow">if</span> (value == 0) {
<a name="l00080"></a>00080                         <a class="code" href="gpio-linux32_8c.html#a77a5b5803345c350546066730a87e22" title="Array zur Simulation der GPIO Ports.">gpio_values</a>[port] = 0;
<a name="l00081"></a>00081                 } <span class="keywordflow">else</span> {
<a name="l00082"></a>00082                         <a class="code" href="gpio-linux32_8c.html#a77a5b5803345c350546066730a87e22" title="Array zur Simulation der GPIO Ports.">gpio_values</a>[port] = 1;
<a name="l00083"></a>00083                 }
<a name="l00084"></a>00084         }
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 
<a name="l00087"></a><a class="code" href="gpio_8h.html#ea6d99743be79991a2a0665efac78f92">00087</a> <span class="keywordtype">void</span> <a class="code" href="gpio-linux32_8c.html#ea6d99743be79991a2a0665efac78f92" title="Legt eine Funktion als Event-Handler für Schreiboperationen auf GPIO Ports fest...">lcv_gpio_simulate_output</a>(<span class="keywordtype">void</span> (*handler)(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> port, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> value))
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089         <a class="code" href="gpio-linux32_8c.html#8e3ff06079c314fdf78536856b9e19da" title="Function-Pointer auf den GPIO-Output-Handler.">gpio_write_handler</a> = handler;
<a name="l00090"></a>00090 }
</pre></div><hr size="1"><address style="text-align: right;"><small>Erzeugt am Wed Dec 19 16:38:17 2007 für LCV Framework von&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>
